Skip to content

BUGFIX: fix segfault on accessing stream type prior to any encoding - #1068

Closed
hmaarrfk wants to merge 2 commits into
PyAV-Org:mainfrom
hmaarrfk:fix_type_segfault
Closed

hmaarrfk wants to merge 2 commits into
PyAV-Org:mainfrom
hmaarrfk:fix_type_segfault

Conversation

@hmaarrfk

@hmaarrfk hmaarrfk commented Jan 3, 2023

Copy link
Copy Markdown
Contributor

No description provided.

@hmaarrfk
hmaarrfk marked this pull request as ready for review January 3, 2023 03:39
@jlaine

jlaine commented Jan 21, 2023

Copy link
Copy Markdown
Member

Looks like a good catch, can you please add a test exercising this condition?

@hmaarrfk

Copy link
Copy Markdown
Contributor Author

Hopefully the test is clear. I hope I got the test directory correct.

Comment thread tests/test_streams.py
# Ensure that all stream properties have sensible values even
# if writing to the stream hasn't started yet
with av.open(self.sandboxed("output.mp4"), "w") as container:
stream = container.add_stream('h264')

@jlaine jlaine Jan 23, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the type unknown when we add a stream?

Could this be related to #1062 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be. I believe that it is because the codec context is only "opened" on first use.

TBH, I only noticedthis since accessing the __repr__ when running my code interactively cause things to crash.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, with #1062 (and my "fix" removed) applied I should update this test with:

diff --git a/tests/test_streams.py b/tests/test_streams.py
index efee029..496d32d 100644
--- a/tests/test_streams.py
+++ b/tests/test_streams.py
@@ -45,4 +45,4 @@ class TestStreams(TestCase):
             assert stream.duration is None
             assert stream.frames == 0
             assert stream.language is None
-            assert stream.type is None
+            assert stream.type == 'video'

@jlaine

jlaine commented Jan 30, 2023

Copy link
Copy Markdown
Member

PR #1062 is going to land if CI doesn't blow up. This still leaves us with the valid segfault you've spotted, but now I'm not sure how to test it anymore..

@hmaarrfk

Copy link
Copy Markdown
Contributor Author

I'm not sure it is so valid anymore. If the pointer is guaranteed to exist, then it is likely that the code is ok right?

I

@hmaarrfk

Copy link
Copy Markdown
Contributor Author

Selfishly, i would much rather you spend your precious time helping us resolve #1045

@hmaarrfk

hmaarrfk commented Feb 2, 2023

Copy link
Copy Markdown
Contributor Author

So #1083 shows that these changes are no longer necessary

@hmaarrfk hmaarrfk closed this Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants